<?php echo $header; ?>
<div class="box">
    <div class="content">
        <h2 class="h2title">Create New Document Type</h2>
        <div>
          <div class="warning" style="margin-top:10px;display:none;" >			
		  </div>
            <table style="width:100%;padding:20px;">
                <tr>
                    <td>
                        <span class="spanlablebold">Document Type Code</span>
                        <input type="text" class="txt" id="txtdoctypecode" name="txtdoctypecode" maxlength="50"/>
                    </td>
                    <td>
                        <span class="spanlablebold">Document Type Name</span>
                        <input type="text" class="txt" id="txtdoctypename" name="txtdoctypename" maxlength="50"/>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<div class="buttonbar">
    <input type="button" value="Save" id="btnsave" name="btnsave" class="btnradius" style="margin-right:10px;"/>
	<input type="button" value="Reset" id="btnreset" name="btnreset" class="btnradius"/>
</div>
<script type="text/javascript">
	 $("#btnsave").click(function(){
	  		$(".warning").hide();
			if (validate()) {
					loading("show");
			   $.ajax({
                url: "<?php echo MAIN_PAGE.'documenttype/documenttypepost';?>",
                type: 'POST',
                data: {
                  doctypecode:$("#txtdoctypecode").val(),
				  doctypename:$("#txtdoctypename").val()
                },
                dataType: 'json',
                success: function(res){				
                    loading('hide');
					if(res.status){					
						$("#btnreset").trigger("click");
					    alert(res.msg);
					}
					else{
					    alert(res.msg);	
					}               
                }
            });
			}
	 });
	 
	  $("#btnreset").click(function(){
	 	$("#txtdoctypename").val('');
		$("#txtdoctypecode").val('');
	 });
	 
	 
	  function validate(){
	 	if($("#txtdoctypecode").val()==""){
			$("#txtdoctypecode").focus();
			$(".warning").text("Please enter document type code").show();
			return false;
		}
		if($("#txtdoctypename").val()==""){
			$("#txtdoctypename").focus();
			$(".warning").text("Please enter document type name").show();
			return false;
		}
		return true;			
	 }
</script>
<?php echo $footer;?>
